export const setDateFromObj = (target: { [key in string]: any }, obj: { [key in string]: any }) => {
  const temTarget = { ...target }
  for (const key in obj) {
    temTarget[key] = obj[key]
  }
  return temTarget
}
export const presistData = (key: string, data: any) => {
  localStorage.setItem(key, JSON.stringify(data))
}
const boundQuery = () => {
  let timer: NodeJS.Timeout
  return (cb: Function, time = 200) => {
    timer && clearTimeout(timer)
    timer = setTimeout(() => {
      cb && cb()
    }, time)
  }
}
export const bound = boundQuery()

export function formatTime(Time: string): string {
  let time = new Date(parseInt(Time))
  let y = time.getFullYear()
  let M = (time.getMonth() + 1).toString().padStart(2, '0')
  let D = time.getDate().toString().padStart(2, '0')
  let h = time.getHours().toString().padStart(2, '0')
  let m = time.getMinutes().toString().padStart(2, '0')
  let s = time.getSeconds().toString().padStart(2, '0')
  return y + '-' + M + '-' + D + '  ' + h + ':' + m + ':' + s
}
export function formatYMTime(Time: string): string {
  let time = new Date(parseInt(Time))
  let y = time.getFullYear()
  let M = time.getMonth() + 1
  return y + '-' + M
}
